package com.stsolutions.budgetcontroller.model.data;

import java.util.Date;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.stsolutions.budgetcontroller.util.FormatDate;

import android.util.Log;

@DatabaseTable(tableName = "cost")
public class Cost {
	/**
	 * Cost class
	 */
	@DatabaseField(canBeNull = false, foreign = true, foreignAutoCreate = true, foreignAutoRefresh = true)
	private CostBucket costBucket;

	@DatabaseField(generatedId = true)
	private int id;

	@DatabaseField(canBeNull = false, foreign = true, foreignAutoCreate = true, foreignAutoRefresh = true)
	private CostType costType;

	@DatabaseField
	private double costValue;

	@DatabaseField
	private Date costDate;

	@DatabaseField
	private String costDescription;

	public Cost() {
	}

	public CostBucket getCostBucket() {
		return costBucket;
	}

	public void setCostBucket(CostBucket costBucket) {
		this.costBucket = costBucket;
	}

	public String getCostDescription() {
		return costDescription;
	}

	public void setCostDescription(String costDescription) {
		this.costDescription = costDescription;
	}

	public CostType getCostType() {
		return costType;
	}

	public void setCostType(CostType costType) {
		this.costType = costType;
	}

	public double getCostValue() {
		return costValue;
	}

	public void setCostValue(double costValue) {
		this.costValue = costValue;
	}

	public Date getCostDate() {
		return costDate;
	}

	public void setCostDate(Date costDate) {
		Log.i(Cost.class.getName(), "setting cost date: " + costDate);
		this.costDate = costDate;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String toString() {

		return costType.getCostTypeName() + "\t" + costValue + "\t"
				+ FormatDate.formatDate(costDate);
	}
}
